home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DOS.SWG / 0075_Yes-No in Batch files.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  1KB  |  41 lines

  1.  
  2. {
  3. This is a VERY simple program to return an
  4. errorlevel based on whether the user pressed Y or N at a Yes/No
  5. prompt.  Has to be simple since the wife uses it.  :-)  I use it in my
  6. batch files to branch to a different option depending on the user's
  7. selection.
  8.  
  9.  
  10. {  Yes/No Errorlevel returner v.000003432ß  }
  11. { Returns errorlevel depending on the key   }
  12. { chosen by the end user.                   }
  13. { by Rick Schaefer                          }
  14. { Donated to the public domain              }
  15.  
  16. Program YNExe;
  17.         Uses Dos,
  18.              Crt;
  19. var
  20.    YN : char;
  21.    i  : integer;
  22.  
  23.    PROCEDURE Color(back, fore : BYTE);
  24.    BEGIN
  25.    TextAttr := (Fore + (Back SHL 4) ) MOD 128;
  26.    END;
  27.  
  28. begin
  29.      color(15,0);
  30.      writeln;
  31.      writeln;
  32.      for i := 1 to paramcount do write(paramstr(i)+' ');
  33.      write(' (Y/N)? ');
  34.      YN := readkey;
  35.      YN := upcase(YN);
  36.      textcolor(14);
  37.      writeln(yn);
  38.      if (YN = 'Y') then halt(1);
  39.      if (YN = 'N') then halt(0);
  40. end.
  41.